home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / echsys10.zip / ECHOSYS.ASM next >
Assembly Source File  |  1989-09-25  |  23KB  |  557 lines

  1. ; EchoSys : show current system data (drive, dir, time, date etc)
  2. ;           for redirection purposes
  3. ;
  4. ; Version 1.0
  5. ;
  6. ; Free Software by TapirSoft Gisbert W.Selke, Sept 1989
  7. ;
  8. ; This programme may be used and copied any way you wish, except don't
  9. ; sell it. Give credit where credit is due, please. - The copyright remains
  10. ; with me; I do not guarantee proper operation of this utility; the whole
  11. ; risk of use lies with the user.
  12. ;
  13. ; Usage:   echosys <string>
  14. ;          String is echoed to stdout; two-char sequences introduced by '^'
  15. ;          are replaced as indicated at 'Usage' below.
  16. ;
  17. ; TASM     echosys                  or        MASM   echosys
  18. ; TLINK /t echosys                            LINK   echosys
  19. ;                                             EXEBIN echosys.exe echosys.com
  20.  
  21. BackSpace       Equ     08h
  22. LineFeed        Equ     0Ah
  23. Return          Equ     0Dh
  24. CtrlZ           Equ     1Ah
  25.  
  26.  
  27. DisplayAL       Macro                           ; macro to echo the
  28.                 Mov     dl, al                  ; contents of AL to stdout
  29.                 Mov     ah, 02h
  30.                 Int     21h
  31.                 Endm
  32.  
  33. DisplayChar     Macro   Chr                     ; macro to echo a character
  34.                 Mov     dl, Chr                 ; character to stdout
  35.                 Mov     ah, 02h
  36.                 Int     21h
  37.                 Endm
  38.  
  39. Jmps            Macro   Label                   ; Jump short
  40.                 Jmp short Label
  41.                 Endm
  42.  
  43.  
  44. cseg            Segment
  45.  
  46.                 Org 0080h
  47. Parameter       Db      ?
  48.  
  49.                 Org 100h
  50.                 Assume CS:cseg, DS:cseg, ES:cseg
  51.  
  52. Start:          Jmp     Begin
  53.  
  54.                 db      'SPECIAL='
  55. Special         db      '^'
  56.  
  57.                 db      Return
  58. Copyright       db      'EchoSys 1.0 - Free software by TapirSoft'
  59.                 db      ' Gisbert W.Selke, Sept 89', Return, LineFeed
  60.                 db      'Use at your own risk.$', BackSpace, ' '
  61.                 db      Return, LineFeed, CtrlZ
  62.  
  63. Usage1          db      Return, LineFeed, LineFeed
  64.                 db      'Usage: echosys <string>', Return, LineFeed
  65.                 db      'The string is echoed to stdout with "$'
  66. Usage2          db      '@" replaced as indicated by @:', Return, LineFeed
  67.                 db      ': drive; \ directory; F free disk space; '
  68.                 db      'T total disk space; R free RAM;', Return, LineFeed
  69.                 db      'r RAM size; l #drives; f #floppies; P #printers; '
  70.                 db      'S #serial ports;', Return, Linefeed
  71.                 db      '7 coprocessor? L LPT1 status; V video mode; '
  72.                 db      'w screen width; t type of PC;', Return, LineFeed
  73.                 db      'v DOS version; b BIOS version; i "<" symbol; '
  74.                 db      'o ">" symbol; p "|" symbol; ', Return, LineFeed
  75.                 db      'O switch char; A author''s note; '
  76.                 db      'x char given by next 2 hex digits;', Return, LineFeed
  77.                 db      'K key typed by user; C country code; $'
  78. Usage3          db      ' currency string;', Return, LineFeed
  79.                 db      'k 1000s separator; 1 decimal separator; '
  80.                 db      '/ date separator; - time separator;'
  81.                 db      Return, LineFeed
  82.                 db      'D day; M month; Y year; W weekday; h hour; m minute; '
  83.                 db      's second; c centisecond.'
  84.                 db      Return, LineFeed, Return, LineFeed, '$'
  85.  
  86. RetVal          db      0
  87.  
  88. ModelString     db      '??80AP30??ATJRXTPC'
  89. ModelStrLen     Label   Byte
  90.  
  91. CmdLetters      db      'csmhWYMD-/1k$CpoiKxAObvtwVL7SPflRrTF\:';command letters
  92. EndCmdLetters   Label   Word
  93.  
  94. ; **NOTE**: order of CmdLetters and Dispatch is reversed w.r.t. each other!
  95.  
  96. Dispatch        dw      Drive, Directory, FreeSpace, TotalSpace, MemSize
  97.                 dw      FreeMem, LogicDrives, Floppies, Printers
  98.                 dw      CommPorts, Coproc, LptStat, VideoMode, VideoWidth
  99.                 dw      SysModel, DosVersion, BiosVersion, SwitchChar, Author
  100.                 dw      Hexnumber, KeyBoard
  101.                 dw      StdInSymbol, StdOutSymbol, PipeSymbol, CountryInfo
  102.                 dw      Currency, Thousands, Decimal, DateSep, TimeSep
  103.                 dw      Day, Month, Year, WeekDay
  104.                 dw      Hour, Minute, Second, CentiSecond
  105.  
  106.  
  107. Begin:          Mov     sp, Offset OurStack     ; point to our own stack
  108.                 Mov     bx, Offset ProgEnd + 15 ; pointer to end of programme
  109.                 Mov     cl, 4                   ; convert size to paragraphs
  110.                 ShR     bx, cl
  111.                 Mov     ah, 4Ah                 ; return unused memory to DOS
  112.                 Int     21h
  113.  
  114.                 Mov     ah, 2Ch                 ; get current time right now
  115.                 Int     21h
  116.                 Mov     [TimeBuf],   ch         ; stow away
  117.                 Mov     [TimeBuf+1], cl
  118.                 Mov     [TimeBuf+2], dh
  119.                 Mov     [TimeBuf+3], dl
  120.                 Mov     ah, 2Ah                 ; get current date
  121.                 Int     21h
  122.                 Sub     cx, 1900                ; remove centuries
  123.                 Mov     word ptr [DateBuf], cx  ; stow away
  124.                 Mov     [DateBuf+2], dh
  125.                 Mov     [DateBuf+3], dl
  126.                 Mov     [DateBuf+4], al
  127.  
  128.                 Mov     si, 1+offset Parameter  ; command line string
  129.                 Lodsb
  130.                 Cmp     al, ' '                 ; skip first char, if
  131.                 Je      NextChar                ; blank or tab
  132.                 Cmp     al, 09h
  133.                 Je      NextChar
  134.                 Cmp     al, Return
  135.                 Jne     CheckSpecials
  136.                 Mov     dx, offset Copyright    ; show author's note
  137.                 Mov     ah, 09h
  138.                 Int     21h
  139.                 Mov     dx, offset Usage1       ; show usage hints
  140.                 Mov     ah, 09h
  141.                 Int     21h
  142.                 DisplayChar Special
  143.                 Mov     dx, offset Usage2       ; more usage hints
  144.                 Mov     ah, 09h
  145.                 Int     21h
  146.                 DisplayChar '$'
  147.                 Mov     dx, offset Usage3       ; more usage hints
  148.                 Mov     ah, 09h
  149.                 Int     21h
  150.                 Mov     [RetVal], 0FFh          ; termination code
  151.                 Jmps    Done
  152.  
  153. NextChar:       Lodsb
  154.                 Cmp     al, Return              ; are we done?
  155.                 Jne     CheckSpecials
  156. Done:           Mov     ah, 4Ch                 ; terminate normally
  157.                 Mov     al, [RetVal]            ; return code
  158.                 Int     21h
  159.  
  160.  
  161. CheckSpecials:  Cmp     al, Special             ; is it special sequence?
  162.                 Je      DoSpecials
  163. CheckSp2:       DisplayAL                       ; otherwise just display it
  164.                 Jmps    NextChar                ; and loop
  165.  
  166. DoSpecials:     Lodsb                           ; get next char of sequence
  167.                 Mov     di, offset CmdLetters   ; look up in table
  168.                 Mov     cx, (offset EndCmdLetters) - (offset CmdLetters)
  169.                 Repne   Scasb
  170.                 Jz      DoSp2                   ; jump if found
  171.                 Cmp     al, Return              ; otherwise: are we done?
  172.                 Je      Done
  173.                 Jmps    CheckSp2                ; otherwise treat normal
  174.  
  175. DoSp2:          Add     cx, cx                  ; double for Word
  176.                 Mov     bx, cx
  177.                 Call    [dispatch+bx]           ; call the subroutine
  178.                 Jmps    NextChar
  179.  
  180.  
  181. Drive:          Mov     ah, 19h                 ; get current drive
  182.                 Int     21h
  183.                 Add     al, 41h                 ; convert to ASCII
  184.                 Mov     [RetVal], al            ; store for return
  185.                 DisplayAL                       ; and show it
  186.                 DisplayChar ':'                 ; and a colon
  187.                 Ret
  188.  
  189.  
  190. Directory:      Mov     c